<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>

	<%-- 	Benvenuto  --%>
	Benvenuto
	<sec:authentication property="principal" />

	<form:form modelAttribute="bookCriteria" method="GET" action="do.htm">
		<table>
			<tr>
				<td><form:label path="title">Titolo:</form:label></td>
				<td><form:input path="title" /></td>
			</tr>
		</table>

		<input type="submit" value="Search" />

		<!-- Questo tasto compare solo agli admin -->
		<sec:authorize access="hasRole('ROLE_ADMIN')">
			<input type="button" value="Insert" onclick="" />
		</sec:authorize>

		<input type="button" value="Logout"
			onclick="location.href='../logout.htm'" />
	</form:form>
	<c:if test="${!empty list}">
		<table>
			<thead>
				<tr>
					<th>Titolo</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${list}" var="book">
					<tr>
						<td><c:out value="${book.title}" /></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:if>

</body>
</html>